import os
import time
from time import sleep
from selenium.webdriver.common.by import By
from selenium.webdriver import Keys
from common.base import Base
from selenium import webdriver
from common.functions import open_browser


class DetailPage(Base):
    # 点击商品管理标签
    def click_goods_management(self):
        self.base_click((By.XPATH, '//div[@id="menu-list"]/ul/li[2]'))

    # 点击添加新商品标签
    def click_add_new_goods(self):
        self.base_click((By.LINK_TEXT, '添加新商品'))

    # 点击详细描述按钮
    def click_goods_detail(self):
        self.base_switch_default_iframe()
        self.base_switch_iframe((By.ID, 'main-frame'))
        self.base_click((By.ID, "detail-tab"))

    # 详细描述输入框输入信息
    def send_info(self, content):
        self.base_switch_default_iframe()
        self.base_switch_iframe((By.ID, "main-frame"))
        self.base_switch_iframe((By.ID, "goods_desc___Frame"))
        self.base_switch_iframe((By.XPATH, "//td[@id='xEditingArea']/iframe"))
        self.base_send_keys((By.TAG_NAME, "body"), content)

    # 点击重置按钮
    def reset(self):
        self.base_switch_default_iframe()
        self.base_switch_iframe((By.ID, "main-frame"))
        self.base_click((By.XPATH, "//div[@class='button-div']/input[3]"))

    # 点击确定按钮
    def sure(self):
        self.base_switch_default_iframe()
        self.base_switch_iframe((By.ID, "main-frame"))
        self.base_click((By.XPATH, "//div[@class='button-div']/input[2]"))

